package User;

/**
 * 
 * The User class allows different actions for a User. A User is someone who can browse the
 * web site, register, login, logout, get login username and password from the database, and 
 * change password.
 * 
 * @author John Santos
 */
public class User
{
    private int userID;
    private int playerID;
    private String username;
    private String firstName;
    private String lastName;
    private String password;


    /**
     * default empty constructor needed for JSP/Servlets and Database Classes
     */
    public User(){
        
    }

    
    /**
     * initializer needed by the Database Class
     * 
     * @param userID the id of the user auto-generated by the database
     * @param username the login username
     * @param password the login password
     * @param firstName the user's real name
     * @param lastName the user's real name

     */
    public void initializeUser(int userID, String username, String password, String firstName, String lastName){
        this.userID = userID;
        this.username = username;
        this.firstName = firstName;
        this.lastName = lastName;
        this.password = password;
        this.playerID = -1;
    }
    
    
    /**
     * initializer without user ID
     * 
     * @param username the login username
     * @param password the login username
     * @param firstName the user's real name
     * @param lastName the user's real name
     */
    public void initializeUser(String username, String password, String firstName, String lastName)
    {
        this.username = username;
        this.firstName = firstName;
        this.lastName = lastName;
        this.password = password;
        this.playerID = -1;
    }
    
    /**
     * Sets the login username.
     * @param username login
     */
    public void setUsername(String username){
        this.username = username;
    }
    
    /**
     * Gets the login username.
     * @return String login
     */
    public String getUsername(){
        return username;
    }
    
    /**
     * Sets the login password
     * @param password login
     */
    public void setPassword(String password){
        this.password = password;
    }

    /**
     * Get the login password
     * @return String password login
     */
    public String getPassword(){
        return password;
    }

    /**
     * Get the User's first name
     * @return String first name
     */
    public String getFirstName() {
        return firstName;
    }

    /**
     * Set the User's first name
     * @param firstName the User's first name 
     */
    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    /**
     * Get the User's last name
     * @return String the User's first name
     */
    public String getLastName() {
        return lastName;
    }

    /**
     * Set the User's last name
     * @param lastName 
     */
    public void setLastName(String lastName) {
        this.lastName = lastName;
    }
    
    /**
     * the database gives the user a player id when the player is created at the start of a game
     * This should only be set by the Database Controller when it creates a new Player.
     * @param id the player id that is associated with this User in the database
     */
    public void setPlayerID(int id){
        playerID = id;
    }

    /**
     * the database gives the user a player id when the player is created at the start of a game
     * @return int the player id that is associated with this User in the database
     */
    public int getPlayerID(){
        return playerID;
    }
   
    /**
     * Set the database id for the registered User.
     * This should only be set by the Database Controller when it creates a new User.
     * @param id the User id
     */
    // id is auto assigned by the database when the user is created the first time by registering
    public void setUserID(int id){
        userID = id;
    }

    /**
     * Get the database id for the registered User.
     * @return int the User id
     */
    public int getUserID(){
        return userID;
    }
}
